import React from 'react';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';

interface ErrorDialogProp {
  message: string;
  isError: boolean;
  setIsError: (val: boolean) => void;
}
export function ErrorDialog({ message, isError, setIsError }: ErrorDialogProp) {
  return (
    <div>
      <Dialog
        open={isError}
        onClose={e => setIsError(false)}
        aria-labelledby="alert-dialog-title"
        aria-describedby="alert-dialog-description"
      >
        <DialogTitle id="alert-dialog-title">{'请求失败'}</DialogTitle>
        <DialogContent>
          <DialogContentText id="alert-dialog-description">失败原因：{message}</DialogContentText>
        </DialogContent>
        <DialogActions>
          <Button onClick={e => setIsError(false)} color="primary">
            关闭
          </Button>
        </DialogActions>
      </Dialog>
    </div>
  );
}
